import java.io.*;

public class Demo_OutputStream {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("d:/test/test1/file8.txt")){
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
            PrintWriter printWriter = new PrintWriter(outputStreamWriter);
            printWriter.println("你好世界");
            printWriter.flush();
        }catch(Exception e){
            e.printStackTrace();
        }

    }
    public static void main3(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("d:/test/test1/file7.txt", true)){
            String s = "hello world";
            byte[] b = s.getBytes();
            outputStream.write(b);
            outputStream.flush();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main2(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("d:/test/test1/file7.txt")){
            String s = "hello world";
            byte[] b = s.getBytes();
            outputStream.write(b);
            outputStream.flush();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main1(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("d:/test/test1/file6.txt")){
            outputStream.write('H');
            outputStream.write('e');
            outputStream.write('l');
            outputStream.write('l');
            outputStream.write('o');
            outputStream.flush();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
